Skip to content

Migrating to const/let and Object Spread in more places#11535

Merged
gaearon merged 2 commits intofacebook:masterfrom
raphamorim:master
Nov 19, 2017
Merged

Migrating to const/let and Object Spread in more places#11535
gaearon merged 2 commits intofacebook:masterfrom
raphamorim:master

Conversation

@raphamorim
Copy link
Copy Markdown
Contributor

@raphamorim raphamorim commented Nov 12, 2017

@raphamorim raphamorim changed the title Migrating to const/let and Object Spread (react-dom), format folders Migrating to const/let and Object Spread (react-dom) Nov 12, 2017
@raphamorim raphamorim changed the title Migrating to const/let and Object Spread (react-dom) Migrating to const/let and Object Spread in more places Nov 12, 2017
@raphamorim raphamorim force-pushed the master branch 2 times, most recently from fe1a6e7 to 669a157 Compare November 12, 2017 23:22
};

var didWarn = {};
let didWarn = {};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be a const, since it's never re-assigned.

var ancestorInfo = Object.assign({}, oldInfo || emptyAncestorInfo);
var info = {tag: tag, instance: instance};
const updatedAncestorInfo = function(oldInfo, tag, instance) {
let ancestorInfo = {...{}, ...(oldInfo || emptyAncestorInfo)};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think you need ...{}


// https://html.spec.whatwg.org/multipage/syntax.html#special
var specialTags = [
let specialTags = [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?


var value = props.value;
var initialValue = value;
let initialValue = props.value;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, wonder why it was written the other way initially. 😛

Copy link
Copy Markdown
Contributor Author

@raphamorim raphamorim Nov 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

te-hehe

Do you recommend putting it back?
I think it does not make sense to keep this line. Since it is the same reference.
Tradeoff: I guess it was written for better readability.

What do you think @clemmy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is probably fine.

});
const hostProps = {
...props,
...{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about:

  const hostProps = {
    ...props,
    value: undefined,
    defaultValue: undefined,
    children: '' + node._wrapperState.initialValue,
  };

var hostProps = Object.assign({children: undefined}, props);

var content = flattenChildren(props.children);
const hostProps = {...{children: undefined}, ...props};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar:

const hostProps = {children: undefined, ...props};

Copy link
Copy Markdown
Contributor

@clemmy clemmy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if the comments I made make sense. :)

* Convert ReactDOMFiberTextarea to const/let
* Convert ReactDOMSelection to const/let
* Convert setTextContent to const/let
* Convert validateDOMNesting to const/let
* Convert ReactDOMFiberOption to Object Spread
* Convert ReactDOMFiberTextarea to Object Spread
* Convert validateDOMNesting to Object Spread
@raphamorim
Copy link
Copy Markdown
Contributor Author

raphamorim commented Nov 13, 2017

Makes a lot of sense :D
Thanks for the review @clemmy. I squashed the changes 👍

@gaearon gaearon merged commit 3f405da into facebook:master Nov 19, 2017
Ethan-Arrowood pushed a commit to Ethan-Arrowood/react that referenced this pull request Dec 8, 2017
* Use const/let in more places (facebook#11467)

* Convert ReactDOMFiberTextarea to const/let
* Convert ReactDOMSelection to const/let
* Convert setTextContent to const/let
* Convert validateDOMNesting to const/let

* Replace Object.assign by Object Spread

* Convert ReactDOMFiberOption to Object Spread
* Convert ReactDOMFiberTextarea to Object Spread
* Convert validateDOMNesting to Object Spread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants